﻿using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using System;
using System.Security.Claims;
using static System.Runtime.InteropServices.JavaScript.JSType;

using Icon = AntDesign.Icon;

namespace SageKing.Blazor.OpenIdService.Components.Base;

public class AuthComponentTabBase : AuthComponentBase, IReuseTabsPage
{

    #region Tab

    [SupplyParameterFromQuery]
    public string TabTitle { get; set; } = "默认标题";
    public string TabIcon = "setting";

    public void UpdateTab()
    {
        ReuseTabsService.Update();
    }
    public virtual RenderFragment GetPageTitle()
    {
        RenderFragment frag = builder =>
        {
            builder.OpenElement(0, "span");

            // 嵌套组件
            builder.OpenComponent<Icon>(1);
            builder.AddAttribute(2, "Type", TabIcon);
            builder.AddAttribute(3, "Theme", IconThemeType.Outline);
            builder.CloseComponent(); // 关闭组件

            builder.OpenElement(5, "span");
            builder.AddContent(6, TabTitle);
            builder.CloseElement();

            builder.CloseElement();
        };
        return frag;
    }
    #endregion
}
